You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The EmptyResult does two different things: act as a base type for all BiDi results, and act as a void result. We can separate these two responsibilities to two different types, leading to clearer code. Additionally, we can rest assured that any EmptyResult we get is not non-empty result without at runtime.
PR Type
Enhancement, Other
Description
Replaced EmptyResult with BiDiResult as the base type for BiDi command results.
Refactored multiple command result classes to inherit from BiDiResult.
Updated serialization and deserialization logic to accommodate the new BiDiResult type.
Improved code clarity by separating void results (EmptyResult) from the base result type.
The Write method for ElementOrigin is missing the actual serialization of the element.Element property. The code adds the property name but doesn't complete the serialization process.
The code is using options.GetTypeInfo() which appears to be a custom extension method, but there's no indication that this method exists in the standard JsonSerializerOptions class. This could lead to runtime errors if the method is not properly defined or accessible.
Why: The suggestion correctly identifies a potential issue with the serialization method. The PR changed the serialization from using options directly to using options.GetTypeInfo<ISharedReference>(), which is a custom extension method that might not be properly defined or accessible, potentially causing runtime errors. Reverting to the original approach would be safer.
High
Learned best practice
Add null validation before accessing object properties to prevent potential NullReferenceExceptions
The code is accessing element.Element without first checking if it's null. This could lead to a NullReferenceException if the Element property is null. Add a null check before serializing the element to prevent potential runtime exceptions.
The EmptyResult does two different things: act as a base type for all BiDi results, and act as a void result.
True, we will avoid user facing Task DoSomething() and rework to Task<Result> DoSomething() in #15562. If we agree, then separating BiDiResult and EmptyResult is unnecessary I think.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
💥 What does this PR do?
The
EmptyResultdoes two different things: act as a base type for all BiDi results, and act as a void result. We can separate these two responsibilities to two different types, leading to clearer code. Additionally, we can rest assured that anyEmptyResultwe get is not non-empty result without at runtime.PR Type
Enhancement, Other
Description
Replaced
EmptyResultwithBiDiResultas the base type for BiDi command results.Refactored multiple command result classes to inherit from
BiDiResult.Updated serialization and deserialization logic to accommodate the new
BiDiResulttype.Improved code clarity by separating void results (
EmptyResult) from the base result type.Changes walkthrough 📝
25 files
Update command execution to use `BiDiResult`Introduce `BiDiResult` and refactor command baseUpdate JSON serialization for `BiDiResult`Adjust serialization logic for shared referencesUpdate message success handling to use `BiDiResult`Refactor `GetClientWindowsResult` to inherit `BiDiResult`Refactor `GetUserContextsResult` to inherit `BiDiResult`Update `UserContextInfo` to inherit `BiDiResult`Refactor `CaptureScreenshotResult` to inherit `BiDiResult`Update `CreateResult` to inherit `BiDiResult`Refactor `GetTreeResult` to inherit `BiDiResult`Update `LocateNodesResult` to inherit `BiDiResult`Refactor `NavigateResult` to inherit `BiDiResult`Update `PrintResult` to inherit `BiDiResult`Refactor `TraverseHistoryResult` to inherit `BiDiResult`Update `AddInterceptResult` to inherit `BiDiResult`Refactor `AddPreloadScriptResult` to inherit `BiDiResult`Update `EvaluateResult` hierarchy to inherit `BiDiResult`Refactor `GetRealmsResult` to inherit `BiDiResult`Update `NewResult` to inherit `BiDiResult`Refactor `StatusResult` to inherit `BiDiResult`Update `SubscribeResult` to inherit `BiDiResult`Refactor `DeleteCookiesResult` to inherit `BiDiResult`Update `GetCookiesResult` to inherit `BiDiResult`Refactor `SetCookieResult` to inherit `BiDiResult`